package com.ipworkbench.ipw.systemsettings.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ipworkbench.common.struts2.action.BaseAction;
import com.ipworkbench.ipw.systemsettings.entity.Menu;
import com.ipworkbench.ipw.systemsettings.entity.User;
import com.ipworkbench.ipw.systemsettings.manager.MenuMgr;

@SuppressWarnings("serial")
public class MenuAct extends BaseAction {
	
	private Menu getEntity(){
		User user = (User) getSession("");
		Menu entity = new Menu();
		
		entity.setMenu_name(menuName);
		entity.setParent_id(parentId);
		entity.setMenu_icon(menuIcon);
		entity.setMenu_url(menuUrl);
		entity.setMenu_desc(menuDesc);
		entity.setLast_modify(user.getUser_id());
		entity.setLast_modify_time(new Date());
		
		return entity;
	}
	
  public String showMenuTree(){
		
	    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
	    List<Map<String, Object>> list2 = new ArrayList<Map<String, Object>>();
	    
		Map<String, Object> map=new HashMap<String,Object>();
		Map<String,Object> map1=new HashMap<String,Object>();
		Map<String,Object> map2=new HashMap<String,Object>();
		Map<String,Object> map3=new HashMap<String,Object>();
		Map<String,Object> map4=new HashMap<String,Object>();
		
		map1.put("id", "2");
		map1.put("text", "系统管理");
		map1.put("children",list2);
		
		map2.put("id", "3");
		map2.put("text", "本所信息");
		
		map3.put("id", "4");
		map3.put("text", "用户部门");
		
		map4.put("id", "5");
		map4.put("text", "用户角色");
		
		list.add(map1);
		list2.add(map2);
		list2.add(map3);
		list2.add(map4);
		
		map.put("id", "1");
		map.put("text", "IPWorkbench");
		map.put("iconCls", "icon-ok");
		map.put("children",list);
		map.put("state","close");
		 
		jsonList.add(map);
		return SUCCESS;
	}
	
  public String showMenuTreeList(){
		
	  List<Map<String, String>> list2 = new ArrayList<Map<String, String>>();
		Map<String, String> map=new HashMap<String,String>();
		Map<String, String> map2=new HashMap<String,String>();
		
		map2.put("id", "1");
		map2.put("name", "系统管理");
		map2.put("createTime", "2012-05-01");
		map2.put("upLastDate", "2012-05-06");
		map2.put("status", "1");
		list2.add(map2);
		
		map.put("id", "2");
		map.put("name", "组织机构");
		map.put("createTime", "2012-05-01");
		map.put("upLastDate", "2012-05-06");
		map.put("status", "1");
		map.put("_parentId", "1");
		
		list2.add(map);
		map.put("id", "3");
		list2.add(map2);
		list2.add(map2);
		list2.add(map2);
		list2.add(map2);
		list2.add(map2);
		list2.add(map2);
		list2.add(map2);
		list2.add(map2);
		list2.add(map2);
		list2.add(map2);
		jsonMap.put("total",list2.size());//total键 存放总记录数，必须的           列表
		jsonMap.put("rows",list2);//rows键 存放每页记录 list  
		 
		return SUCCESS;
	}
  
	private MenuMgr mgr;
	
	public MenuMgr getMgr(){
		if(null == mgr){
			mgr = new MenuMgr();
		}
		return mgr;
	}
	
	private String menuName;
	private Long parentId;
	private String menuIcon;
	private String menuUrl;
	private String menuDesc;

	public String getMenuName() {
		return menuName;
	}
	public void setMenuName(String menuName) {
		this.menuName = menuName;
	}
	public Long getParentId() {
		return parentId;
	}
	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
	public String getMenuIcon() {
		return menuIcon;
	}
	public void setMenuIcon(String menuIcon) {
		this.menuIcon = menuIcon;
	}
	public String getMenuUrl() {
		return menuUrl;
	}
	public void setMenuUrl(String menuUrl) {
		this.menuUrl = menuUrl;
	}
	public String getMenuDesc() {
		return menuDesc;
	}
	public void setMenuDesc(String menuDesc) {
		this.menuDesc = menuDesc;
	}
	
	
}
